package org.example.myerp.service.serviceimpl;

import java.io.Console;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.example.myerp.dto.*;
import org.example.myerp.mapper.ProductMapper;
import org.example.myerp.mapper.ProductMapper2;
import org.example.myerp.pojo.PageMyself;
import org.example.myerp.pojo.*;
import org.example.myerp.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProductServiceImpl implements ProductService {

	@Autowired
    ProductMapper ductMapper;

	@Autowired
    ProductMapper2 ductMapper2;

	@Override
	public PageMyself<Producess> ProcessfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<Producess> page = new PageMyself<Producess>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<Producess> lis = ductMapper.findByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper.pageTotal());
		return page;
	}

	@Override
	public void updateProcess(Producess process) {
		ductMapper.updateProcess(process);
	}

	@Override
	public void insertProcess(Producess process) {
		ductMapper.insertProcess(process);

	}

	@Override
	public void delProcess(Integer[] id) {
		for (int i = 0; i < id.length; i++) {
			ductMapper.delProcess(id[i]);
		}

	}

	@Override
	public PageMyself<MakeProcess> makeProByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<MakeProcess> page = new PageMyself<MakeProcess>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<MakeProcess> lis = ductMapper.makeproByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper.makePageTotal());
		return page;
	}

	@Override
	public void addNewMakeProcess(MakepsDto makepsDto) {
		ProproSheet proproSheet = makepsDto.getProproSheet();
		ductMapper.addNewMakeProcess(proproSheet);
		List<DproList> dproList = makepsDto.getDproList();

		for (int i = 0; i < dproList.size(); i++) {
			DproList dproList2 = new DproList();
			dproList2 = dproList.get(i);
			dproList2.setPducess_id(proproSheet.getPducess_id());
			dproList2.setPucess_gid(i + 1);
			ductMapper.addNewMakeProcessDeatils(dproList2);
		}
		double selProcessSsumPrice = ductMapper.selProcessSsumPrice(proproSheet.getPducess_id(),
				proproSheet.getProSige_id());
		ductMapper.updProcessSsumPrice(proproSheet.getPducess_id(), proproSheet.getProSige_id(), selProcessSsumPrice);
		ductMapper.updProFileGxSigin(proproSheet.getProSige_id());

	}

	@Override
	public PageMyself<ProproSheet> auditProcessfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProproSheet> page = new PageMyself<ProproSheet>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProproSheet> lis = ductMapper.auditProcessfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper.auditProcesspageTotal());
		return page;
	}

	@Override
	public List<DproList> makeProcessSh(Integer pducess_id, Integer proSige_id) {

		return ductMapper.makeProcessSh(pducess_id, proSige_id);
	}

	@Override
	public void addNewMakeProcessSh(MakepsDto makepsDto) {
		ProproSheet proproSheet = makepsDto.getProproSheet();
		Integer proSige_id = proproSheet.getProSige_id();
		Integer pducess_id = proproSheet.getPducess_id();
		ductMapper.addNewMakeProcessh(makepsDto.getProproSheet());
		List<DproList> dproList = makepsDto.getDproList();
		for (int i = 0; i < dproList.size(); i++) {
			dproList.get(i).setProSige_id(proSige_id);
			dproList.get(i).setPducess_id(pducess_id);
			ductMapper.addNewMakeProcessDeatilsh(dproList.get(i));
		}
		double selProcessSsumPrice = ductMapper.selProcessSsumPrice(proproSheet.getPducess_id(),
				proproSheet.getProSige_id());
		proproSheet.setGongShiPrice(selProcessSsumPrice);
		ductMapper.addNewMakeProcesshPrice(proproSheet);
	}

	@Override
	public PageMyself<ProproSheet> processWuLiaofindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProproSheet> page = new PageMyself<ProproSheet>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProproSheet> lis = ductMapper.proceseedesginfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper.proceseedesginPageTotal());
		return page;
	}

	@Override
	public List<MaterialList> selProcessdesginWuliao(Integer proSige_id) {
		return ductMapper.selProcessdesginWuliao(proSige_id);
	}

	@Override
	public void setProcessWuliao(MakepsDto makepsDto) {
		List<MaterialList> materialList = makepsDto.getMaterialList();
		System.err.println(materialList.size());
		for (int i = 0; i < materialList.size(); i++) {
			if (materialList.get(i).getWunum() == null || materialList.get(i).getWunum().equals("")) {
				materialList.get(i).setWunum(0);
			}
			ductMapper.insertProcessWuliao(materialList.get(i));
			ductMapper.updateWuliakeyongNum(materialList.get(i));
			ductMapper.udpateProcessCxsj(materialList.get(i));
		}
	}

	@Override
	public void updateProcessWucount(DproList dproList) {
		ductMapper.updateProcessWucount(dproList);

	}

	@Override
	public void repalceWuliao(MaterialList materialList) {
		List<MaterialList> wuliao = ductMapper.selreplaceWuliao(materialList);
		for (int i = 0; i < wuliao.size(); i++) {
			MaterialList list = new MaterialList();
			list = wuliao.get(i);
			ductMapper.updatereplaceWuliao(list);
		}
		ductMapper.updatereplaceProcess(materialList);
		ductMapper.deletereplaceWuliao(materialList);
	}

	@Override
	public void wcProcessWoLiaoSigin(ProproSheet ProproSheet) {
		ductMapper.wcProcessWoLiaoSigin(ProproSheet);
	}

	@Override
	public PageMyself<ProproSheet> newProcessWiliaoSh(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProproSheet> page = new PageMyself<ProproSheet>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProproSheet> lis = ductMapper.newProcessWiliaoSh(params);
		page.setRows(lis);
		page.setTotal(ductMapper.newProcessWiliaoPageTotal());
		return page;
	}

	@Override
	public List<MaterialList> shProcessWuliaoInfo(DproList dproList) {
		// TODO Auto-generated method stub
		return ductMapper.shProcessWuliaoInfo(dproList);
	}

	@Override
	public void processWuliaoShUpdate(ProproSheet proproSheet) {
		ductMapper.processWuliaoShUpdate(proproSheet);
	}

	@Override
	public Integer KeNumCount(Integer proSige_id) {
		return ductMapper.KeNumCount(proSige_id);
	}

	@Override
	public void updateProcessGxwl(ProproSheet proproSheet) {
		ductMapper.updateProcessGxwl(proproSheet);
	}

	@Override
	public PageMyself<NewPlanDetail> NewPlanAddProductfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<NewPlanDetail> page = new PageMyself<NewPlanDetail>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<NewPlanDetail> lis = ductMapper.NewPlanAddProductfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper.NewPlanAddProductPageTotal());
		return page;
	}

	@Override
	public void addNewPlan(MakepsDto makepsDto) {
		NewPlan newPlan = makepsDto.getNewPlan();
		List<NewPlanDetail> newPlanDetail = makepsDto.getNewPlanDetail();
		ductMapper.addNewPlan(newPlan);
		for (int i = 0; i < newPlanDetail.size(); i++) {
			NewPlanDetail newPlanDetail2 = newPlanDetail.get(i);
			newPlanDetail2.setNewpro_id(newPlan.getNewpro_id());
			ductMapper.addNewPlanDetail(newPlanDetail2);
		}
	}

	@Override
	public PageMyself<NewPlan> newPlanSh(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<NewPlan> page = new PageMyself<NewPlan>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<NewPlan> lis = ductMapper.newPlanShfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper.newPlanShPageTotal());
		return page;
	}

	@Override
	public List<NewPlanDetail> selNewPlanDetailsh(Integer newpro_id) {
		return ductMapper.selNewPlanDetailsh(newpro_id);
	}

	@Override
	public void okNelPlansh(NewPlan newPlan) {
		ductMapper.okNelPlansh(newPlan);
		ductMapper.okNelPlanDetailsh(Integer.valueOf(newPlan.getNewpro_id()));
	}

	@Override
	public void noNelPlansh(Integer newpro_id) {
		// TODO Auto-generated method stub
		ductMapper.noNelPlansh(newpro_id);
		ductMapper.noNelPlanDetailsh(newpro_id);
	}

	@Override
	public PageMyself<NewPlanDetail> selNewPlanByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<NewPlanDetail> page = new PageMyself<NewPlanDetail>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<NewPlanDetail> lis = ductMapper.selNewPlanByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper.selNewPlanPageTotal());
		return page;
	}

	@Override
	public Integer productPlanAudit(Integer proSige_id) {
		return ductMapper.productPlanAudit(proSige_id);
	}

	@Override
	public List<PdoProcess> proBaiGongDan(Integer proSige_id) {
		// TODO Auto-generated method stub
		return ductMapper.proBaiGongDan(proSige_id);
	}

	@Override
	public void insertProDisOder(MakepsDto makepsDto) {
		// TODO Auto-generated method stub
		ProDisOrder proDisOrder = makepsDto.getProDisOrder();
		ductMapper.insertProDisOder(proDisOrder);
		Chuku chuku = new Chuku();
		chuku.setScpgd_id(proDisOrder.getScpgd_id());
		chuku.setProSige_id(proDisOrder.getProSige_id());
		ductMapper.insertRep_wltd(chuku);
		List<PdoProcess> pdoProcess = makepsDto.getPdoProcess();
		for (int i = 0; i < pdoProcess.size(); i++) {
			PdoProcess pdoProcess2 = pdoProcess.get(i);
			System.out.println(pdoProcess2);
			pdoProcess2.setScpgd_id(proDisOrder.getScpgd_id());
			pdoProcess2.setProSige_id(proDisOrder.getProSige_id());
			ductMapper.insertPdoProcess(pdoProcess2);
			List<PdoProcessWuLiao> pdoProcessWuLiaos = pdoProcess2.getPdoProcessWuLiaos();
			for (int j = 0; j < pdoProcessWuLiaos.size(); j++) {
				// scpgd_id
				PdoProcessWuLiao pdoProcessWuLiao = pdoProcessWuLiaos.get(j);
				pdoProcessWuLiao.setScpgd_id(proDisOrder.getScpgd_id());
				pdoProcessWuLiao.setScpgd_process_id(pdoProcess2.getScpgd_process_id());
				pdoProcessWuLiao.setProSige_id(proDisOrder.getProSige_id());
				ductMapper.insertPdoProcessWuliao(pdoProcessWuLiao);
			}
		}
		List<KuCun> selShejiwuliao = ductMapper.selShejiwuliao(proDisOrder.getProSige_id());
		for (int i = 0; i < selShejiwuliao.size(); i++) {
			KuCun kuCun = selShejiwuliao.get(i);
			Chuku chu = new Chuku();
			chu.setChukuid(chuku.getChukuid());
			chu.setNum(kuCun.getNum() * proDisOrder.getNum());
			chu.setPid(kuCun.getPid());
			ductMapper.insertRep_wltd_dateis(chu);
		}
	}

	@Override
	public void UpdateNewxsScjh(Integer[] id) {
		ductMapper.UpdateNewxsScjh(id);
	}

	@Override
	public PageMyself<ProDisOrder> scjhshfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProDisOrder> page = new PageMyself<ProDisOrder>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProDisOrder> lis = ductMapper.scjhshfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper.scjhshpageTotal());
		return page;
	}

	@Override
	public List<PdoProcess> selPdoProcess(Integer scpgd_id) {
		return ductMapper.selPdoProcess(scpgd_id);
	}

	@Override
	public void okshpgd(ProDisOrder proDisOrder) {

		ductMapper.okshpgd(proDisOrder);
	}

	@Override
	public void delPdo(Integer scpgd_id) {
		// TODO Auto-generated method stub
		ductMapper.delPdoProcessWuliao(scpgd_id);
		ductMapper.delPdoProcess(scpgd_id);
		;
		ductMapper.delProDisOder(scpgd_id);
	}

	@Override
	public List<KuCun> selwuliao(Integer proSige_id) {
		// TODO Auto-generated method stub
		return ductMapper.selShejiwuliao(proSige_id);
	}

	@Override
	public PageMyself<ProDisOrder> scdjfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProDisOrder> page = new PageMyself<ProDisOrder>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProDisOrder> lis = ductMapper.scdjfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper.scdjPageTotal());
		return page;
	}

	@Override
	public List<PdoProcess> scdjselinfo(Integer scpgd_id) {
		// TODO Auto-generated method stub
		return ductMapper.scdjselinfo(scpgd_id);
	}

	@Override
	public List<PdoProcessWuLiao> scdjselinfoWuliao(Integer scpgd_process_id) {
		// TODO Auto-generated method stub
		return ductMapper.scdjselinfoWuliao(scpgd_process_id);
	}

	@Override
	public void scdjUpdate(ScdjDto scdjDto) {

		List<PdoProcessWuLiao> pdoProcessWuLiao = scdjDto.getPdoProcessWuLiao();
		for (int i = 0; i < pdoProcessWuLiao.size(); i++) {
			PdoProcessWuLiao pdoProcessWuLiao2 = pdoProcessWuLiao.get(i);
			if (Integer.valueOf(pdoProcessWuLiao2.getProcessesNum()) != 0) {
				ductMapper.updatespdjWuliao(pdoProcessWuLiao2);
			}
		}

		PdoProcess pdoProcesss = scdjDto.getPdoProcess();
		ductMapper.updatespdjProcess(pdoProcesss);
		ProDisOrder proDisOrder = new ProDisOrder();
		proDisOrder.setProSige_id(pdoProcesss.getProSige_id());
		proDisOrder.setSjGongShiPrice(pdoProcesss.getSjGScount());
		proDisOrder.setSjWuliaoSumPrice(pdoProcesss.getSjWlcount());
		proDisOrder.setScpgd_id(pdoProcesss.getScpgd_id());
		ductMapper.updatespdj(proDisOrder);
	}

	@Override
	public void scdjUpdatesh(ScdjDto scdjDto) {
		PdoProcess pdoProcesss = scdjDto.getPdoProcess();
		ductMapper.updatespdjProcess(pdoProcesss);
		List<PdoProcessWuLiao> pdoProcessWuLiao = scdjDto.getPdoProcessWuLiao();
		for (int i = 0; i < pdoProcessWuLiao.size(); i++) {
			PdoProcessWuLiao pdoProcessWuLiao2 = pdoProcessWuLiao.get(i);
			if (Integer.valueOf(pdoProcessWuLiao2.getProcessesNum()) != 0) {
				ductMapper.updatespdjWuliao(pdoProcessWuLiao2);
			}
		}
		ductMapper.shscdj(pdoProcesss.getScpgd_process_id());

		Integer selsjWlcount = ductMapper.selsjWlcount(pdoProcesss.getScpgd_id());
		ProDisOrder proDisOrder = new ProDisOrder();
		proDisOrder.setScpgd_id(pdoProcesss.getScpgd_id());
		proDisOrder.setSjWuliaoSumPrice(selsjWlcount);
		ductMapper.updatespdj2(proDisOrder);

	}

	@Override
	public PageMyself<ProDisOrder> spdjshfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProDisOrder> page = new PageMyself<ProDisOrder>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProDisOrder> lis = ductMapper.spdjshfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper.spdjshPageTotal());
		return page;
	}

	@Override
	public void updateSjNum(Integer sjnum, Integer scpgd_process_id) {
		ductMapper.updateSjNum(sjnum, scpgd_process_id);
	}

	@Override
	public void updateSjNum2(Integer sjnum, Integer scpgd_process_id, Integer scpgd_id,Integer proSige_id) {
		ductMapper.updateSjNum2(sjnum, scpgd_process_id);

		Integer scdjsh = ductMapper.isScdjsh(scpgd_id);
		Integer scdjshCount = ductMapper.isScdjshCount(scpgd_id);
		if (scdjsh == scdjshCount) {
			ductMapper.updateScdjsh(sjnum, scpgd_id);
			Chuku chuku = new Chuku();
			chuku.setScpgd_id(scpgd_id);
			chuku.setProSige_id(proSige_id);
			chuku.setNum(sjnum);
			ductMapper.insertRep_wltdchu(chuku);
		}

	}

	@Override
	public Integer selgid(Integer scpgd_process_id) {
		Integer falg = 0;
		Integer selgid = ductMapper.selgid(scpgd_process_id);
		if (selgid == 1) {
			falg = 0;
		} else {
			Integer selgids = ductMapper.selgids(scpgd_process_id - 1);
			if (selgids == 1) {
				falg = 0;
			} else {
				falg = 1;

			}
		}

		return falg;
	}

	@Override
	public PageMyself<ProDisOrder> SjCxfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProDisOrder> page = new PageMyself<ProDisOrder>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProDisOrder> lis = ductMapper2.SjCxfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper2.SjCxpageTotal());
		return page;
	}

	@Override
	public List<PdoProcess> selscProcess(Integer scpgd_id) {
		return ductMapper2.selscProcess(scpgd_id);
	}

	@Override
	public PageMyself<ProDisOrder> wcCtfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProDisOrder> page = new PageMyself<ProDisOrder>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProDisOrder> lis = ductMapper2.wcCtfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper2.wcCtPageTotal());
		return page;
	}

	@Override
	public PageMyself<ProproSheet> scgxchfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProproSheet> page = new PageMyself<ProproSheet>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProproSheet> lis = ductMapper2.scgxchfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper2.scgxchwcCtPageTotal());
		return page;
	}

	@Override
	public List<DproList> cxProducess(Integer pducess_id) {
		// TODO Auto-generated method stub
		return ductMapper2.cxProducess(pducess_id);
	}

	@Override
	public PageMyself<ProproSheet> cpsjbgfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProproSheet> page = new PageMyself<ProproSheet>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProproSheet> lis = ductMapper2.cpsjbgfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper2.cpsjbgPageTotal());
		return page;
	}

	@Override
	public void replaceProcess(MakepsDto makepsDto) {
		ProproSheet proproSheet = makepsDto.getProproSheet();
		ductMapper2.replaceProcess(proproSheet);
		ductMapper2.repDelProcessDeatil(proproSheet.getPducess_id());
		ductMapper2.repDelProcessDeatilWuliao(proproSheet.getPducess_id());
		ductMapper2.repUpdateWuliaoDesgin(proproSheet.getProSige_id());
		List<DproList> dproList = makepsDto.getDproList();
		for (int i = 0; i < dproList.size(); i++) {
			DproList dproList2 = dproList.get(i);
			dproList2.setPucess_gid((i + 1));
			ductMapper.addNewMakeProcessDeatils(dproList2);
		}
	}

	@Override
	public PageMyself<ProproSheet> gxwlcxfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProproSheet> page = new PageMyself<ProproSheet>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProproSheet> lis = ductMapper2.gxwlcxfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper2.gxwlcxPageTotal());
		return page;
	}

	@Override
	public List<MaterialList> selreplaceWuliao(MaterialList materialList) {
		// TODO Auto-generated method stub
		return ductMapper.selreplaceWuliaos(materialList);
	}

	@Override
	public PageMyself<ProproSheet> gxwlbgfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProproSheet> page = new PageMyself<ProproSheet>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProproSheet> lis = ductMapper2.gxwlbgfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper2.gxwlbgPageTotal());
		return page;
	}

	@Override
	public void gswlbgprocess(Integer pducess_id, Integer processesid) {
		ductMapper2.gswlbgprocess(pducess_id);
		ductMapper2.gswlbgprocessisgxwl(pducess_id, processesid);
		Integer gswlwugCount = ductMapper2.gswlwugCount(pducess_id);
		ductMapper2.gswlwugCounts(gswlwugCount, pducess_id);
		List<MaterialList> selMaterialList = ductMapper2.selMaterialList(pducess_id, processesid);
		for (int i = 0; i < selMaterialList.size(); i++) {
			MaterialList materialList = selMaterialList.get(i);
			Integer gxwumWunum = ductMapper2.gxwumWunum(materialList);
			ductMapper2.gxwumWunumbg(gxwumWunum, materialList.getProSige_id(), materialList.getWid());

		}
		ductMapper2.wuNumbg(pducess_id, processesid);

	}

	@Override
	public void gxwicxsj(MakepsDto makepsDto) {
		List<MaterialList> list = makepsDto.getMaterialList();
		for (int i = 0; i < list.size(); i++) {

			MaterialList materialList = list.get(i);
			if (materialList.getWunum() == null || materialList.getWunum() == 0 || materialList.getWunum().equals("")) {
				materialList.setWunum(0);
			}
			ductMapper2.gxwicxsj(materialList);
			ductMapper.updateWuliakeyongNum(materialList);
			Integer wuCount = ductMapper2.wuCount(materialList);
			DproList dproList = new DproList();
			System.err.println("���������մ������쪵�     " + wuCount);
			ductMapper2.updategxWugCount(wuCount, materialList.getPducess_id(), materialList.getProcessesid());

			Integer gswlwugCount = ductMapper2.gswlwugCount(materialList.getPducess_id());
			ductMapper2.gswlwugCounts(gswlwugCount, materialList.getPducess_id());

		}
	}

	@Override
	public void gxwlbgWang(Integer pducess_id) {
		ductMapper2.gxwlbgWang(pducess_id);
	}

	@Override
	public PageMyself<ProDisOrder> wcCtfindByPagers(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<ProDisOrder> page = new PageMyself<ProDisOrder>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<ProDisOrder> lis = ductMapper2.wcCtfindByPagers(params);
		page.setRows(lis);
		page.setTotal(ductMapper2.wcCtPageTotals());
		return page;
	}

	@Override
	public PageMyself<NewPlan> newPlanListfindByPager(Integer pageNum, Integer pageSize) {
		Map params = new HashMap<String, Object>();
		params.put("pageNum", pageNum);
		params.put("pageSize", pageSize);
		PageMyself<NewPlan> page = new PageMyself<NewPlan>();
		page.setPageNum(pageNum);
		page.setPageSize(pageSize);
		List<NewPlan> lis = ductMapper2.newPlanListfindByPager(params);
		page.setRows(lis);
		page.setTotal(ductMapper2.newPlanListPageTotal());
		return page;
	}

	@Override
	public List<NewPlanDetail> selNewPlanDetail(Integer newpro_id) {
		// TODO Auto-generated method stub
		return ductMapper2.selNewPlanDetail(newpro_id);
	}

	@Override
	public Integer preProcessNum(Integer scpgd_id, Integer pucess_gid) {
		// TODO Auto-generated method stub
		return ductMapper2.preProcessNum(scpgd_id, pucess_gid);
	}



}
